<?php
/**
 * Header Template
 * 
 * @package WP Bootstrap Woo
 */

defined('ABSPATH') || exit;
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    
    <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
    <?php wp_body_open(); ?>
    
    <!-- screen-bg start -->
    <div class="screen-bg"></div>
    <!-- screen-bg end -->
    
    <!-- preloader start -->
    <div class="preloader"></div>
    <!-- preloader end -->
    
    <!-- top notification start -->
    <div class="top-notification-bar">
        <div class="container">
            <ul class="notification-entry">
                <li class="notify-wrap notify-mail">
                    <div class="notify-text">
                        <ul class="grid-wrap">
                            <li class="grid-wrapper">
                                <p class="notification-free"><span class="top-c">Free delivery</span> on orders over $100 discount</p>
                            </li>
                        </ul>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <!-- top notification end -->
    
    <!-- header-area start -->
    <header id="header" class="main-header stickyheader">
        <div class="header-area">
            <div class="container">
                <div class="main-menu-area">
                    <div class="main-menu-wrap">
                        <!-- header-logo start -->
                        <div class="header-theme-logo">
                            <?php if (has_custom_logo()) : ?>
                                <?php the_custom_logo(); ?>
                            <?php else : ?>
                                <a href="<?php echo esc_url(home_url('/')); ?>" class="theme-logo">
                                    <img src="<?php echo get_template_directory_uri(); ?>/assets/images/home1/logo.png" class="img-fluid" alt="<?php bloginfo('name'); ?>">
                                </a>
                            <?php endif; ?>
                        </div>
                        <!-- header-logo end -->
                        
                        <!-- search-wrapper start -->
                        <div class="header-element header-search">
                            <div class="header-theme-search">
                                <form method="get" action="<?php echo esc_url(home_url('/')); ?>" class="search-form">
                                    <div class="search-bar">
                                        <div class="form-search">
                                            <input type="search" name="s" class="search-input" value="<?php echo get_search_query(); ?>" placeholder="Search our store" required="">
                                            <button type="submit" class="search-btn"><i class="feather-search"></i></button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <!-- search-wrapper end -->
                        
                        <!-- header-icon start -->
                        <div class="header-icon-block">
                            <ul class="shop-element">
                                <li class="side-wrap toggler-wrap">
                                    <div class="toggler-wrapper">
                                        <button type="button" class="toggler-btn"><span class="toggler-icon"><i class="feather-menu"></i></span></button>
                                    </div>
                                </li>
                                <li class="side-wrap search-wrap">
                                    <div class="search-wrapper">
                                        <a href="#searchmodal" data-bs-toggle="modal">
                                            <span class="search-icon"><i class="feather-search"></i></span>
                                        </a>
                                    </div>
                                </li>
                                <li class="side-wrap user-wrap">
                                    <div class="user-info">
                                        <a href="javascript:void(0)">
                                            <span class="user-icon"><i class="feather-user"></i></span>
                                        </a>
                                        <div class="account-main">
                                            <span class="acc-title">Account</span>
                                            <div class="account-login">
                                                <?php if (is_user_logged_in()) : ?>
                                                    <a href="<?php echo wc_get_page_permalink('myaccount'); ?>">My Account</a>
                                                    <a href="<?php echo wp_logout_url(home_url()); ?>">Logout</a>
                                                <?php else : ?>
                                                    <a href="<?php echo wc_get_page_permalink('myaccount'); ?>">Register</a>
                                                    <a href="<?php echo wc_get_page_permalink('myaccount'); ?>">Log in</a>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                <?php if (class_exists('WooCommerce')) : ?>
                                <li class="side-wrap wishlist-wrap">
                                    <div class="wishlist-wrapper">
                                        <a href="#">
                                            <span class="wishlist-icon-count">
                                                <span class="wishlist-icon"><i class="feather-heart"></i></span>
                                                <span class="wishlist-count">(0)</span>
                                            </span>
                                        </a>
                                    </div>
                                </li>
                                <li class="side-wrap cart-wrap">
                                    <div class="cart-wrapper">
                                        <a href="<?php echo wc_get_cart_url(); ?>" class="js-cart-drawer">
                                            <span class="cart-icon-count">
                                                <span class="cart-icon"><i class="feather-shopping-bag"></i></span>
                                                <span class="cart-count cart-counter">(<?php echo WC()->cart->get_cart_contents_count(); ?>)</span>
                                            </span>
                                        </a>
                                    </div>
                                </li>
                                <?php endif; ?>
                            </ul>
                        </div>
                        <!-- header-icon end -->
                    </div>
                </div>
            </div>
        </div>
        
        <!-- main navigation -->
        <div class="menu-main">
            <div class="container">
                <div class="menu-contact">
                    <!-- main-menu start -->
                    <div class="mega-menu-area">
                        <div class="mainmenu-content">
                            <div class="main-wrap">
                                <?php
                                if (has_nav_menu('main-menu')) {
                                    wp_nav_menu(array(
                                        'theme_location' => 'main-menu',
                                        'menu_class' => 'main-menu',
                                        'container' => false,
                                        'depth' => 3,
                                        'fallback_cb' => false
                                    ));
                                } else {
                                    // 默认菜单结构
                                    ?>
                                    <ul class="main-menu">
                                        <li class="menu-link">
                                            <a href="<?php echo home_url(); ?>" class="link-title">
                                                <span class="sp-link-title">Home</span>
                                            </a>
                                        </li>
                                        <?php if (class_exists('WooCommerce')) : ?>
                                        <li class="menu-link">
                                            <a href="<?php echo wc_get_page_permalink('shop'); ?>" class="link-title">
                                                <span class="sp-link-title">Shop</span>
                                            </a>
                                        </li>
                                        <?php endif; ?>
                                        <li class="menu-link">
                                            <a href="<?php echo get_permalink(get_option('page_for_posts')); ?>" class="link-title">
                                                <span class="sp-link-title">Blog</span>
                                            </a>
                                        </li>
                                        <li class="menu-link">
                                            <a href="#" class="link-title">
                                                <span class="sp-link-title">Contact</span>
                                            </a>
                                        </li>
                                    </ul>
                                    <?php
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                    <!-- main-menu end -->
                </div>
            </div>
        </div>
    </header>
    <!-- header-area end -->
    
    <!-- search modal start -->
    <div class="search-modal modal fade" id="searchmodal" aria-modal="true" role="dialog">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-body">
                    <button type="button" class="search-close" data-bs-dismiss="modal"><i class="feather-x"></i></button>
                    <div class="search-info">
                        <form method="get" action="<?php echo esc_url(home_url('/')); ?>" class="search-form">
                            <div class="search-wrap">
                                <input type="search" name="s" placeholder="Search here..." required>
                                <button type="submit" class="btn-style1">Search</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- search modal end -->